export type InternalNamePath = (string | number)[];
export type NamePath = string | number | InternalNamePath;

// store的值
export type StoreValue = any;
export type Store = Record<string, StoreValue>;

export interface FormInstance<Values = any> {
  getFieldValue: (name: NamePath) => StoreValue;
  setFieldValue: (name: NamePath, value: any) => void;
  setCallbacks: (callbacks: Callbacks) => void;
  submit: () => void;
}

export interface Callbacks<Values = any> {
  onFinish?: (values: Values) => void;
}

export type BaseFormProps = Omit<
  React.FormHTMLAttributes<HTMLFormElement>,
  "onSubmit" | "children"
>;

export interface FormProps<Values = any> extends BaseFormProps {
  initialValues?: Store;
  form?: FormInstance<Values>;
  name?: string;
  onFinish?: Callbacks<Values>["onFinish"];
}
